**# Bookmark #1 Setting

*Windows
global root  = "G:/Dropbox/Environmental Injustice/Empirical"
global rawdata = "$root/rawdata"
global workdata = "$root/workdata"
global results = "$root/results"
global outfile = "$root/outfile"

cd "$workdata"

**# Bookmark #2 Panel A

use "$outfile/Table S13 Panel A.dta",clear

rwolf2 (reghdfe codemission belowcl_post,absorb(i.city i.province#i.year) cluster(i.province i.year)) ///
	   (reghdfe entrynum belowcl_post,absorb(i.city i.province#i.year) cluster(i.province i.year)) ///
	   (reghdfe exitnum belowcl_post,absorb(i.city i.province#i.year) cluster(i.province i.year)), ///
		indepvars(belowcl_post,belowcl_post,belowcl_post) cluster(province year) ///
		seed(12345) noplusone usevalid

reghdfe codemission belowcl_post,absorb(i.city i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",replace ctitle("City-level COD Emission") ///
addtext(City FE, YES, Firm FE, NO, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)

reghdfe entrynum belowcl_post,absorb(i.city i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("Firm Entry") ///
addtext(City FE, YES, Firm FE, NO, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)

reghdfe exitnum belowcl_post,absorb(i.city i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("Firm Exit") ///
addtext(City FE, YES, Firm FE, NO, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)
	

**# Bookmark #3 Panel B

use "$outfile/Table S13 Panel B.dta",clear

rwolf2 (reghdfe codemission belowcl_post,absorb(i.id i.province#i.year) cluster(i.province i.year)) ///
	   (reghdfe dummycod belowcl_post,absorb(i.id i.province#i.year) cluster(i.province i.year)) ///
       (reghdfe codemission belowcl_post if dummycod==1,absorb(i.id i.province#i.year) cluster(i.province i.year)) ///
       (reghdfe lncod belowcl_post if dummycod==1,absorb(i.id i.province#i.year) cluster(i.province i.year)) ///
       (reghdfe lnemissionperoutput belowcl_post if dummycod==1,absorb(i.id i.province#i.year) cluster(i.province i.year)), ///
		indepvars(belowcl_post,belowcl_post,belowcl_post,belowcl_post,belowcl_post) cluster(province year) ///
		seed(12345) noplusone usevalid

reghdfe codemission belowcl_post,absorb(i.year i.id i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("Firm-level COD Emission") ///
addtext(City FE, NO, Firm FE, YES, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)

reghdfe dummycod belowcl_post,absorb(i.year i.id i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("COD Emission (=1)") ///
addtext(City FE, NO, Firm FE, YES, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)

reghdfe codemission belowcl_post if dummycod==1,absorb(i.year i.id i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("Firm-level COD Emission") ///
addtext(City FE, NO, Firm FE, YES, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)

reghdfe lncod belowcl_post if dummycod==1,absorb(i.year i.id i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("Log(Firm-level COD Emission)") ///
addtext(City FE, NO, Firm FE, YES, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)

reghdfe lnemissionperoutput belowcl_post if dummycod==1,absorb(i.year i.id i.province#i.year) cluster(i.province i.year)
outreg2 using "$results/Table S13.xls",append ctitle("Log(Firm-level COD Emission/Output)") ///
addtext(City FE, NO, Firm FE, YES, ProvincebyYear FE,YES) ///
bdec(3) tdec(3) rdec(3)
